################################################################################
#
# ipc-shm
#
################################################################################
S32_IPCF_VERSION = 1.0
S32_IPCF_SOC_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32_PLATFORM))
S32_IPCF_SOC_SUB_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32G_PLATFORM))
S32_IPCF_SITE = $(TOPDIR)/package/nxp/s32/s32-ipcf/$(BR2_PACKAGE_NXP_S32_PLATFORM)-ipc-shm
S32_IPCF_SITE_METHOD := local
S32_IPCF_INSTALL_TARGET := YES

S32_IPCF_SINGLE_MODULE = sample/ipc-shm-sample.ko
S32_IPCF_MULTI_MODULE = sample_multi_instance/ipc-shm-sample_multi_instance.ko

S32_IPCF_MODULE_DIRS = $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)

S32_IPCF_MAKE_FLAGS = \
	CROSS_COMPILE=$(TARGET_CROSS) \
	KERNELDIR=$(LINUX_DIR) \
	PLATFORM_FLAVOR=$(S32_IPCF_SOC_SUB_PLATFORM)

define S32_IPCF_BUILD_CMDS
	$(MAKE1) $(S32_IPCF_MAKE_FLAGS) -C $(@D)
	if [ "$(BR2_PACKAGE_S32_IPCF_SAMPLE_INSTANCE)" = "y" ]; then \
		$(MAKE1) $(S32_IPCF_MAKE_FLAGS) -C $(@D)/sample; \
	fi
	if [ "$(BR2_PACKAGE_S32_IPCF_MULTI_INSTANCE)" = "y" ]; then \
		$(MAKE1) $(S32_IPCF_MAKE_FLAGS) -C $(@D)/sample_multi_instance; \
	fi
endef

define S32_IPCF_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 0755 $(@D)/ipc-shm-cdev.ko $(S32_IPCF_MODULE_DIRS)/extra/ipc-shm-cdev.ko
	$(INSTALL) -D -m 0755 $(@D)/ipc-shm-dev.ko $(S32_IPCF_MODULE_DIRS)/extra/ipc-shm-dev.ko
	$(INSTALL) -D -m 0755 $(@D)/ipc-shm-uio.ko $(S32_IPCF_MODULE_DIRS)/extra/ipc-shm-uio.ko
	$(INSTALL) -D -m 0755 $(@D)/ipc-shm-xen.ko $(S32_IPCF_MODULE_DIRS)/extra/ipc-shm-xen.ko
	if [ "$(BR2_PACKAGE_S32_IPCF_SAMPLE_INSTANCE)" = "y" ]; then \
		$(INSTALL) -D -m 0755 $(@D)/$(S32_IPCF_SINGLE_MODULE) $(S32_IPCF_MODULE_DIRS)/extra/ipc-shm-sample.ko; \
	fi
	if [ "$(BR2_PACKAGE_S32_IPCF_MULTI_INSTANCE)" = "y" ]; then \
		$(INSTALL) -D -m 0755 $(@D)/$(S32_IPCF_MULTI_MODULE) $(S32_IPCF_MODULE_DIRS)/extra/ipc-shm-sample_multi_instance.ko; \
	fi
endef

$(eval $(generic-package))
